<?php
header("Access-Control-Allow-Origin:*");
require("../lib/init.php");
require("../pojo/admin.php");
require("../pojo/token.php");
$username = $_POST['username'];
$password = $_POST['password'];
if (Login($username, $password)) {
    $roleName = GetRoleName($username, $password);
    $token = getToken($username, $password);
    $code = 200;
    $msg = "登录成功！";
    $data = array(
        "username" => $username,
        "password" => md5($password),
        "roleName" => $roleName,
        "token" => $token
    );
} else {
    $code = 400;
    $msg = "用户名或密码错误！";
    $data = array(
        "username" => $username,
        "password" => md5($password)
    );
}
echo json_encode(result($code, $msg, $data));
